home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / fastkey.exe / FASTKEY.DOC < prev    next >
Text File  |  1992-12-11  |  15KB  |  265 lines

  1.                           FastKey v1.1 for Turbo Pascal 6.0
  2.                                FastKey v1.0 for Turbo C
  3.                            Copyright 1992 by Steve Holley.
  4.  
  5.   Opening Rambling:
  6.        While writing my first arcade game for the IBM PC, I discovered that
  7.        the standard keyboard routines that I had available were not good
  8.        enough.  I needed a method to handle the key presses as soon as the
  9.        program was ready for them.  There was also a slight delay that
  10.        occurred when you switch between keys that you have been holding
  11.        down.  After much coding and research, I developed a routine that
  12.        would monitor the keyboard with enough speed to please me.  At the
  13.        suggestion of a good friend, and since I was unable to find a similar
  14.        product while developing my code (that would have saved me a lot of
  15.        time), I have decided to release a unit for Turbo Pascal 6.0 that
  16.        improves keyboard handling.  Special thanks to Curtis Keisler for the
  17.        conversion of the assembler code to a Turbo Pascal Unit and for his
  18.        suggestions.
  19.  
  20.   What FastKey is:
  21.        FastKey is an interrupt driven routine that monitors the keyboard,
  22.        keeping track of which keys are pressed and which are not.  At any
  23.        given time you can check to see which keys are pressed since the
  24.        interrupt occurs asynchronous to the rest of your program.  This may
  25.        sound strange but for arcade games it is a good way of handling the
  26.        keyboard.  It allows the program to process keyboard input as soon as
  27.        the program is ready for it.  I do not recommend this routine for
  28.        standard business applications since it does not buffer the input or
  29.        process the keyboard in the same way that the normal interrupt does. 
  30.        Also, any TSR (Terminate and Stay Resident) programs that use the
  31.        keyboard interrupt will not work with FastKey.  In general, as soon
  32.        as you install FastKey your program has the whole computer to itself. 
  33.        As soon as FastKey is removed, the TSRs will work properly.  While
  34.        FastKey is installed the following Turbo Pascal procedures and
  35.        functions should not be used: Readln, KeyPressed and ReadKey.  If you
  36.        attempt to uses these routines the computer may lock-up.  
  37.  
  38.   Disclaimer:
  39.        I wish that I did not have to include this section but due to the
  40.        highly "sue-able" state of the world, the following section is,
  41.        unfortunately, required.  FastKey is distributed "as is", with no
  42.        guarantee that it will work properly in any or all programs or
  43.        combinations of hardware.  The Author assumes no liability for any
  44.        damages, financial, software or hardware, caused by the use, misuse,
  45.        or modification of this product, nor is he liable if part of a
  46.        passing 747 falls on your house destroying your computer while using
  47.        this product.
  48.  
  49.   Distribution:
  50.        You may freely distribute unmodified copies of the FastKey package
  51.        (all files listed in the README file) so long as any fee charged is
  52.        for distribution costs only.  Commercial distribution strictly
  53.        prohibited.
  54.  
  55.   System Requirements:
  56.        1. IBM PC/XT/AT/Jr/PS/2 or 100%
  57.        2. Turbo Pascal(tm) v6.0 or greater
  58.  
  59.   Turbo Pascal and Turbo C are registered trademarks of BORLAND International.
  60.   Compuserve is a registered trademark of Compuserve Incorporated.   Usage:
  61.        FastKey is easy to use.  To make it available to your program just
  62.        include FastKey in your Uses section at the start of your program. 
  63.        See the Turbo Pascal reference manual for help with the Uses command. 
  64.        Only four routines are used in the FastKey unit.  Each is detailed
  65.        below.  For an example of how to use FastKey, examine DEMO2.PAS.
  66.  
  67.        Procedure InstallFastKey;
  68.        Function  FastKeyInstalled : Boolean;
  69.        Function  Pressed (KeyCode : Byte) : Boolean;
  70.        Function  FastKeyPressed : Boolean;
  71.        Procedure UnInstallFastKey;
  72.  
  73.        InstallFastKey
  74.        Before FastKey can be used, it must first be installed.  At the start
  75.        of your program, call InstallFastKey.  I recommend that you do this
  76.        in your main program block or in your initialization routine.  That's
  77.        all there is to the installation.  As soon as it is installed you can
  78.        begin to use Pressed to determine which keys are pressed. 
  79.  
  80.        FastKeyInstalled
  81.        The function FastKeyInstalled is used to determine if FastKey has
  82.        been installed.  It will return true if FastKey has been installed. 
  83.        You probably will not use it but it is there if you need it.
  84.  
  85.        Pressed(KeyCode)
  86.        Pressed will return a boolean value indicating the status of any key
  87.        on the keyboard.  See Key Code Table at the end of this document for
  88.        a list of each of the keys and their key code.  A value of TRUE
  89.        indicates that the key is pressed.  A value of FALSE means it is not. 
  90.        Note that any combination of keys may be checked by successive calls
  91.        to pressed.  For example to determine if both Cursor Up and Cursor
  92.        Left are pressed use the following line:
  93.  
  94.             IF Pressed(FKUP) AND Pressed(FKLEFT) THEN some action
  95.  
  96.        Several useful key combinations are possible by combining boolean
  97.        expressions with Pressed.  It is also possible to check that a key is
  98.        not pressed at the same time as another key is pressed.  If the
  99.        cursor left and right controlled a ships movement on screen, you
  100.        would not want to be able to move if both keys were pressed.  The
  101.        following lines move the ship and insure that only legal key
  102.        combinations are allowed.
  103.  
  104.             IF Pressed(FKLEFT) AND NOT Pressed(FKRIGHT) THEN move left
  105.             IF Pressed(FKRIGHT) AND NOT Pressed(FKLEFT) THEN move right
  106.  
  107.        FastKeyPressed
  108.        The function FastKeyPressed is used to see if any key is currently
  109.        pressed, perhaps to see if there is a need to check for an complex
  110.        key combination.  It is used exactly the same as the Turbo Pascal
  111.        function Keypressed.
  112.  
  113.        UnInstallFastKey
  114.        It is very important that you remove FastKey from the interrupt table
  115.        before you exit your program.  Failure to do so will result in your
  116.        computer locking up so tightly that you will have to use the big red
  117.        button to bring it back to life.  This should be one of the last
  118.        instructions executed, perhaps in the main program block or a routine
  119.        that resets the computer.   Registration:
  120.        FastKey is distributed as shareware.  The registration fee for
  121.        continued use of the unit is proper credit.  If you use these
  122.        routines in a program, please include something like "FASTKEY
  123.        Keyboard Routines by Steve Holley" in the title screen or
  124.        documentation, and just drop me a note at the following address.  I'd
  125.        like to see what people have been able to do with these routines.  If
  126.        you would like to make a contribution to the author for the use of
  127.        the unit, any amount will be accepted (and is encouraged if you
  128.        charge a fee for your software that uses FastKey.  You decide what is
  129.        fair since only you know how important these routines were to your
  130.        program.).
  131.  
  132.        All source code is available for $20.00.  This includes the original
  133.        .ASM file, an .OBJ file compiled with Borland TASM 2.0 (the best
  134.        assembler on the market), the source code for the Turbo Pascal Unit
  135.        that you already have and the C source code for FastKey, and the
  136.        source & executable for a program to display the key codes generated
  137.        by the keyboard.  All source code is heavily commented to make
  138.        modification and understanding easier.  The source code will come in
  139.        handy if/when TP 7.0 comes out and the unit formats are again
  140.        changed, or you want to add support for a new or non-standard
  141.        keyboard.  With the assembler source code it should